/**
 *********************************************************
 ** <h1>SFMLex - Simple and Fast Multimedia Library Extensions.</h1>
 ** SFMLex Copyright (C) 2008 Neil Johnson (neil@emailus.me.uk)
 ** 
 ** SFML - Simple and Fast Multimedia Library
 ** Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com)
 **
 ** This software is provided 'as-is', without any express or implied warranty.
 ** In no event will the authors be held liable for any damages arising from the use of this software.
 **
 ** Permission is granted to anyone to use this software for any purpose,
 ** including commercial applications, and to alter it and redistribute it freely,
 ** subject to the following restrictions:
 **
 ** 1. The origin of this software must not be misrepresented;
 **    you must not claim that you wrote the original software.
 **    If you use this software in a product, an acknowledgment
 **    in the product documentation would be appreciated but is not required.
 **
 ** 2. Altered source versions must be plainly marked as such,
 **    and must not be misrepresented as being the original software.
 **
 ** 3. This notice may not be removed or altered from any source distribution.
 **
 ************************************************************
 */
#ifndef SFX_C_ANIM_SPRITE_RESOURCE_H
#define SFX_C_ANIM_SPRITE_RESOURCE_H

#include "c_SpriteResource.h"
#include "c_AnimSprite.h"

namespace sfx
{
   /**
    * Defines a class that represents a Animate Sprite Resource.
    * Extends the c_SpriteResource class.
    */
   class c_AnimSpriteResource : public c_SpriteResource
   {
   public:
      
      /**
       * Construct Animate sprite resrouce.
       * @param ResourceMgr A pointer to a resource manager object than owns this resource.
       */
      c_AnimSpriteResource( c_ResourceMgr* ResourceMgr );
      
      /**
       * Creates an instance of a sfx::c_AnimSprite object based on this resources values.
       * This function can be thought of as a factory method. Each call will generate a new animate sprite object based on the 'blue-print' specified in the resource script.
       * This pointer returned should not be deleted by the caller. Use freeAnimSprite() when finished with it.
       * @return A newley create animated sprite object or 0 if creation failed.
       */
      c_AnimSprite* createAnimSprite( void );

      /**
       * Fress a previously created sfx::c_AnimSprite object.
       * Only frees supplied pointer object if it has been created by createAnimSprite(). 
       * @param DeadSprite Animnated Sprite object to free.
       * @return true if succesfull, else false.
       */
      bool freeAnimSprite( c_AnimSprite* DeadSprite );
      
      /**
       * Destructor
       */
      ~c_AnimSpriteResource();
   
   protected:

      /**
       * Resource parameter parse method.
       * Parses the referenced string as Frames Per seconds parameter.
       * @param FPS String representing frames per second.
       */
      void setFPS( const std::string& FPS );       
      
      /**
       * Resource parameter parse method.
       * Parses the referenced string as Number of Animation Frames parameter.
       * @param NumberFrames String representing Number of Animation Frames.
       */ 
      void setNumFrames( const std::string& NumberFrames );

      /**
       * Resource parameter parse method.
       * Parses the referenced string as Frame Width parameter.
       * @param FrameWidth String representing Frame Width in pixels.
       */ 
      void setFrameWidth( const std::string& FrameWidth );

      /**
       * Resource parameter parse method.
       * Parses the referenced string as Frame Height parameter.
       * @param FrameHeight String representing Frame Height in pixels.
       */ 
      void setFrameHeight( const std::string& FrameHeight );

   private:
      
      std::list< c_AnimSprite* > m_AnimSprites; /**< list of sfx::c_AnimSprite objects that have been generated by the resource.*/
      
      bool  m_FPS_Set;         /**< true if m_FPS has been set from resource script. */
      float m_FPS;             /**< Frames Per Seconds parameter. Only valid if m_FPS_Set is true. */

      bool m_NumOfFrames_Set;  /**< true if m_NumOfFrames has been set from resource script. */
      int  m_NumOfFrames;      /**< Number of frames parameter. Only valid if m_NumOfFrames_Set is true. */

      bool m_FrameWidth_Set;   /**< true if m_FrameWidth has been set from resource script. */
      int  m_FrameWidth;       /**< Animation frame width. Only valid if m_FrameWidth_Set is true. */

      bool m_FrameHeight_Set;  /**< true if m_FrameHeight has been set from resource script. */
      int  m_FrameHeight;      /**< Animation frame height. Only valid if m_FrameHeight_Set is true. */
   
   };

}

#endif //SFX_C_ANIM_SPRITE_RESOURCE_H
